<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/* Start of file providers.php */
/* Location: ./billing_ap/models/providers.php */
class Providers extends CI_Model {
    
	function __construct(){
        parent::__construct(); /** Call the Model constructor */
    }
	
	function getDataProviderMbenet(){
		$this->db->where_not_in('ProviderGroup','');
		$Q=$this->db->get('provider_mbenet');
		if ($Q->num_rows() > 0):
			foreach ($Q->result_array() as $row):
				$data[0]				 = lang('sel_customer');
				$data[$row['MeteringName']] = $row['MeteringName'];
			endforeach;
		endif;
        $Q->free_result();
		return $data;   
	}
    
    function getDataProviderMbenetPerGroup(){
        /** select * from provider_mbenet where CustomerGroup!='' and CustomerGroup is not NULL **/
        $this->db->where_not_in('CustomerGroup','');
        $this->db->where_not_in('CustomerGroup','NULL');
		$Q=$this->db->get('provider_mbenet');
		if ($Q->num_rows() > 0):
			foreach ($Q->result_array() as $row):
				$data[0]				 = lang('sel_customer');
				$data[$row['MeteringName']] = $row['MeteringName'];
			endforeach;
		endif;
        $Q->free_result();
		return $data;   
    }
    
    /** select * from daily_log where (month(Tanggal)='$bln' and year(Tanggal)='$thn') and MeteringName='$provider' order by DailyID **/
    function getDailyLogProvider($month,$year,$provider){
        $this->db->select('*,DAY(Tanggal) as day,DAYNAME(Tanggal) as day_name');
        $this->db->where('MONTH(Tanggal)',$month);
        $this->db->where('YEAR(Tanggal)',$year);
        $this->db->where('MeteringName',$provider);
        $this->db->order_by('DailyID','ASC');
        $Q=$this->db->get('daily_log');
        return $Q->result_array();
    }
}    